<?php 

/**
 * 模块的基类,
 */
class Controllers extends Smarty
{
   
    /**
     * [__construct 初始化Smarty配置]
     */
    public function __construct()
    {
        $this->setTemplateDir('./views')
          ->setCompileDir('./runtime/views_a')
          ->setConfigDir('./configs')
          ->setCacheDir('./runtime/caches');
        $this->left_delimiter = LEFT_D;
        $this->right_delimiter = RIGHT_D;
        // 缓存 开关
        $this->caching = CACHING; //开启缓存
        $this->cache_lifetime = CACHE_LIFETIME;//缓存时间
    }

    /**
     * 触发不存在的方法时 停止运行程序
     * @param  str       $name [不存在的方法名]
     * @param  [str arr] $parm [description]
     */
    public function __call($name,$parm)
    {
        header("HTTP/1.0 404 not found");
        echo '<h1>404 NOT FOUND: 来自于控制基类</h1>';
        exit;
    }
    /**
     * [notice 页面跳转]
     * @param  [str] $message  [信息]
     * @param  [str] $url     [网址路径]
     */
    // 跳转重定向
    public function redirect($message, $url=null)
    {
        echo "<script>alert('{$message}')</script>";
        if (empty($url)) {
            echo "<script>history.back()</script>";
        }else{
            echo "<script>location.href='{$url}'</script>";
        }
    }

}




